﻿<div id="cart_info">
	<h1> Az ön kosara az alábbi terméket tartalmazza! </h1>

	<table class="table">
	<tr>
		<th>Termék neve</th>
		<th>Darab ára</th>
		<th>Összesen</th>
		<th>Darab</th>
		<th>Műveletek</th>
	</tr>
	
	<?php 	
		$total = 0;
		
		foreach ($this->cart->contents() as $items) { 
			echo '<tr>';
			echo 	'<td>'. $items['name'] . '</td>';
			echo '	<td>' . $items['price'] . ' Ft</td>';
			echo '	<td>' . $items['price']*$items['qty'] . ' Ft</td>';
			echo '	<td><input class="qty" style="width: 60px;" type="number" min="1" onkeypress="validate(event)" value="'. $items['qty'] .'"></td>';
			echo '	<td><a href="/smaragd/cart/remove/'. $items['rowid'] .'">Törlés</a></td>';
			echo '<tr>';
		}
	?>
	</table>
	<a href="/smaragd/cart/removeall"> Összes termék törlése </a>
	<h2>A teljes összeg: <?php echo $this->cart->total(); ?> Ft</h2>
	<br/>
	<button class="btn btn-success" onclick="window.open('/smaragd/cashier','_self')"> Tovább a pénztárhoz </button>
</div>

<script>
function validate(evt) {
  var theEvent = evt || window.event;
  var key = theEvent.keyCode || theEvent.which;
  key = String.fromCharCode( key );
  var regex = /[0-9]|\./;
  if( !regex.test(key) ) {
    theEvent.returnValue = false;
    if(theEvent.preventDefault) theEvent.preventDefault();
  }
}
</script>